﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace SpriteBatchExtensions
{
    public static class SpriteBatchExtensionsMethods
    {
        static Texture2D t;
        #region DrawRectangle (ou points..)
        public static void DrawRectangle(this SpriteBatch spritebatch, GraphicsDevice graphicsdevice, int x, int y,Color color)
        {
            DrawRectangle(spritebatch, graphicsdevice,new Rectangle( x, y, 1, 1) , color);
        }
        public static void DrawRectangle(this SpriteBatch spritebatch, GraphicsDevice graphicsdevice,Rectangle r)
        {
            DrawRectangle(spritebatch, graphicsdevice, r, Color.Black);
        }
        public static void DrawRectangle(this SpriteBatch spritebatch, GraphicsDevice graphicsdevice, Rectangle r, Color color)
        {
            DrawRectangle(spritebatch, graphicsdevice, r, color, true);
        }
        public static void DrawRectangle(this SpriteBatch spritebatch, GraphicsDevice graphicsdevice, Rectangle r, Color color, bool centered)
        {
            if (t == null)
            {
                t = new Texture2D(graphicsdevice, 1, 1);
                t.SetData<Color>(new Color[] { Color.White });
            }
            if (centered)
            {
                r = new Rectangle(r.X - r.Width / 2, r.Y - r.Height / 2, r.Width, r.Height);
            }
            spritebatch.Draw(t,r, color);
        }
        #endregion
    }
}
